package com.bulemobi.activity.ac_message;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bulemobi.adapter.ViewPagerAdapter;
import com.bulemobi.net.tsz.afinal.annotation.view.ViewInject;
import com.bulemobi.view.BaseActivity;
import com.bulemobi.view.pulltorefreshlist.library.PullToRefreshListView;
import com.jsyh.hcb.R;

import java.util.ArrayList;

/**
 * Created by 武 on 2014/9/19 0019.
 * 消息中心
 */
public class Ac_Message extends BaseActivity implements View.OnClickListener{
    @ViewInject(id = R.id.vPager)
    ViewPager viewPager;
    private LinearLayout lay_break_rules;
    private LinearLayout lay_check;
    private LinearLayout lay_msg_myMsg;
    private PullToRefreshListView lv_check;
    private PullToRefreshListView lv_break_rules;
    private PullToRefreshListView lv_my_Msg;
    @ViewInject(id = R.id.tv_back)
    TextView tv_back;
    @ViewInject(id = R.id.tv_break_rules)
    TextView tv_break_rules;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_msg_main);
        initViewPager();
        initView();
    }

    private void initView(){
        tv_break_rules.setOnClickListener(this);
        tv_back.setOnClickListener(this);
    }

    private void initViewPager(){
        LayoutInflater inflater = getLayoutInflater();
        lay_break_rules = (LinearLayout) inflater.inflate(R.layout.pager_lay_1,null);
        lay_check = (LinearLayout) inflater.inflate(R.layout.pager_lay_2,null);
        lay_msg_myMsg = (LinearLayout)inflater.inflate(R.layout.pager_lay_3,null);
        lv_break_rules = (PullToRefreshListView) lay_break_rules.findViewById(R.id.lv_break_rules);
        lv_check = (PullToRefreshListView) lay_break_rules.findViewById(R.id.lv_check);
        lv_my_Msg = (PullToRefreshListView) lay_break_rules.findViewById(R.id.lv_myMsg);
//        viewPager.addView(lay_break_rules);
//        viewPager.addView(lay_check);
//        viewPager.addView(lay_msg_myMsg);
        ArrayList<View> views = new ArrayList<View>();
        views.add(lay_break_rules);
        views.add(lay_check);
        views.add(lay_msg_myMsg);
        viewPager.setAdapter(new ViewPagerAdapter(views));
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i2) {
                showToastShort("OnPageScrolled");
            }

            @Override
            public void onPageSelected(int i) {
                showToastShort("OnPageSelected");
            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tv_back:
                finish();
                break;
            case R.id.tv_break_rules:
                openActivity(Ac_BreakRulesDetail.class);
                break;
        }
    }
}
